{% extends 'base.html' %}

{% block title %}订单详情{% endblock %}

{% block content %}
<h1 class="mb-4">订单详情 #{{ order.id }}</h1>

<div class="card mb-4">
    <div class="card-body">
        <h5 class="card-title">订单信息</h5>
        <p class="card-text">餐厅：{{ order.restaurant.name }}</p>
        <p class="card-text">状态：{{ order.get_status_display }}</p>
        <p class="card-text">配送地址：{{ order.delivery_address }}</p>
        <p class="card-text">下单时间：{{ order.created_at|date:"Y-m-d H:i" }}</p>
    </div>
</div>

<div class="card mb-4">
    <div class="card-body">
        <h5 class="card-title">订单项目</h5>
        <table class="table">
            <thead>
                <tr>
                    <th>商品</th>
                    <th>数量</th>
                    <th>单价</th>
                    <th>小计</th>
                </tr>
            </thead>
            <tbody>
                {% for item in order.orderitem_set.all %}
                <tr>
                    <td>{{ item.menu_item.name }}</td>
                    <td>{{ item.quantity }}</td>
                    <td>¥{{ item.price }}</td>
                    <td>¥{{ item.price|multiply:item.quantity }}</td>
                </tr>
                {% endfor %}
            </tbody>
            <tfoot>
                <tr>
                    <td colspan="3" class="text-end"><strong>总计：</strong></td>
                    <td><strong>¥{{ order.total_amount }}</strong></td>
                </tr>
            </tfoot>
        </table>
    </div>
</div>
{% endblock %}